package jsd2108.game.server.service;

import com.alibaba.fastjson.JSON;
import jsd2108.game.server.entity.Hero;
import lombok.Data;
import lombok.SneakyThrows;
import lombok.Synchronized;
import lombok.experimental.Accessors;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 接受信息的业务类
 */
@Data
@Accessors(chain = true)
public class SocketService {


    private ServerSocket serverSocket;

    private List<Socket> clientSocket;

    private List<Hero> heroList;

    //这个注解自动捕获异常
    @SneakyThrows
    public SocketService(ServerSocket serverSocket,List<Socket> clientSocket,List<Hero> heroList){
        this.serverSocket = serverSocket;
        this.clientSocket = clientSocket;
        this.heroList = heroList;
    }

    /**
     * 发送英雄的信息
     */
    public void sent(){

        String heroListJSON= JSON.toJSONString(heroList);

        //发送信息给客户端
        //......
    }


}
